<template>
  <div class="dashboard-chart-vbar" ref="vbar"></div>
</template>

<script>
import * as echarts from 'echarts'
import resize from '@/mixin/resize'

export default {
  name: 'ChartVbar',
  mixins: [resize],
  mounted() {
    const myEcharts = echarts.init(this.$refs.vbar)
    myEcharts.setOption({
      xAxis: {
        show: false,
        min: 0,
        max: 100
      },
      yAxis: {
        data: [1],
        show: false
      },
      series: {
        type: 'bar',
        data: [78],
        itemStyle: {
          color: '#FFC0CB'
        },
        // 条形图宽度
        barWidth: 10,
        // 显示柱条的背景色
        showBackground: true,
        // 设置柱条的背景样式
        backgroundStyle: {
          color: '#F0F0F0'
        },
        // 显示标签
        label: {
          show: true,
          // 标签内容格式器
          formatter: '|',
          // 标签颜色
          color: '#FFC0CB',
          // 标签的位置
          position: 'right'
        }
      },
      grid: {
        top: 0,
        bottom: 0,
        left: 0,
        right: 0
      }
    })
    this.myEcharts = myEcharts
  }
}
</script>

<style lang="scss" scoped>
.dashboard-chart-vbar {
  width: 100%;
  height: 100%;
}
</style>
